import bo.edu.umss.jaba.interpreter.*;
import bo.edu.umss.jaba.parser.* ;
import bo.edu.umss.jaba.lexer.* ;
import bo.edu.umss.jaba.node.* ;
import bo.edu.umss.jaba.hashtable.*;

import java.io.* ;
 
public class main {
   public static void main (String[] args) {
      if (args.length > 0) {
         try {
            /* Form our AST */
            Lexer lexer = new Lexer (new PushbackReader(
               new FileReader(args[0]), 1024));
            Parser parser = new Parser(lexer);
            Start ast = parser.parse() ;
	    //Start ast2 = ast;

	    CreateHashtable cht = new CreateHashtable ();
    	    ast.apply (cht);
	    cht.showHash ();

	    lexer = new Lexer (new PushbackReader(new FileReader(args[0]), 1024));
	    parser = new Parser(lexer);
	    ast = parser.parse();



            Interpreter interp = new Interpreter (cht.getHash(), args[0]) ;
            ast.apply(interp) ;
	    interp.cerrar_fichero ();
         }
         catch (Exception e) {
            System.out.println (e) ;
         }
      } else {
         System.err.println("usage: java simpleAdder inputFile");
         System.exit(1);
      }
   }
}
